import pygame
from pygame.locals import *
from Widget import *

class Button(Widget):
   """ Simple button widget. TODO: needs hooks for hover. """
   def __init__(self, rect, label_, font_, fontSize_):
      Widget.__init__(self)
      self.label = label_
      self.rect = pygame.Rect(rect[0], rect[1], rect[2], rect[3])
      self.font = pygame.font.Font(font_, fontSize_)
      self.labelSurface = self.font.render(self.label, 1, (255,255,255))
   def draw(self):
      pygame.draw.rect(self.screen, (95,95,95), 
         (  self.parent.rect.x+self.rect.x, 
            self.parent.rect.y+self.rect.y, 
            self.rect.w, 
            self.rect.h))
      pygame.draw.rect(self.screen, (75,75,75), 
         (  self.parent.rect.x+self.rect.x+1, 
            self.parent.rect.y+self.rect.y+1, 
            self.rect.w-2, 
            self.rect.h-2))
      labelX = (self.getX()) + (self.rect.w/2) - (self.labelSurface.get_width()/2)
      labelY = (self.getY()) + self.rect.h/2 - (self.labelSurface.get_height()/2)
      self.screen.blit(self.labelSurface, ( labelX, labelY, self.rect.w,self.rect.h))